package com.hjw.java.abstract_demo1;

/**
 * @author hjwStrart
 * @create 2022-01-13 10:53
 */
public class Mall {

    /**
     * 办卡，冲10000版金卡，5000办银卡，小于五千大众卡
     * @param money  充值金额
     * @param user   客户姓名
     * @return  办卡，冲10000版金卡，5000办银卡，小于五千大众卡
     */
    public Card applyForACard(Double money,String user){
        if (money == null || money < 0)
            return  null;
        Card card = null;
        String noCard = (int)(Math.random()*9000 + 1000) + "";
        String password = "123456";
        Double balance = money;
        String name = user == null ? "用户" : user;
        if(money >= 10000){
            card = new GoldCard(noCard,password,name,balance);
        }else if(money >= 5000){
            card = new SilverCard(noCard,password,name,balance);
        }else{
            card = new VolkswagenCard(noCard,password,name,balance);
        }
        return card;
    }


}
